package com.zhuhanpeng.cloud.login.control;

import com.zhuhanpeng.cloud.login.service.LoginService;
import com.zhuhanpeng.cloud.mybatis.entity.PtMenuEntity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class MainController {
    private Logger logger = LogManager.getLogger(this.getClass());
    @Resource
    private LoginService loginService;
    @RequestMapping("/")
    public String mainPage(HttpServletRequest request)
    { List<PtMenuEntity> ptMenuEntityList=loginService.queryMenuInfoList();
          request.getSession().setAttribute("menuList",ptMenuEntityList);
        return "login/mainPage";
    }

     @RequestMapping("/homePage")
    public  String homePage(){
        return "login/homePage";

     }

//@RequestMapping("/queryMenuList")
//@ResponseBody
//    public String queryMenuInfoList(){
////    SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//      List<PtMenuEntity> ptMenuEntityList=loginService.queryMenuInfoList();
//        return  JSON.toJSONString(ptMenuEntityList);
//    }

}
